package com.print.androidprintproject;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import com.print.androidprintproject.page.*;

public class MainActivity extends BaseActivity implements View.OnClickListener {

    public static final String TAG = "PRINT_DEMO";
    private LinearLayout llSetPrinter;
    private LinearLayout llLablePrint;
    private LinearLayout llTextPrint;
    private LinearLayout llPDFPrint;
    private LinearLayout llBarcodePrint;
    private LinearLayout llImagePrint;
    private LinearLayout header;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initWnd();
    }

    private void initWnd() {
        header = findViewById(R.id.ll_header_mainactivity);
        llSetPrinter = findViewById(R.id.ll_setting);
        llLablePrint = findViewById(R.id.ll_lable_print);
        llTextPrint = findViewById(R.id.ll_text_print);
        llPDFPrint = findViewById(R.id.ll_pdf_print);
        llBarcodePrint = findViewById(R.id.ll_barcode_print);
        llImagePrint = findViewById(R.id.ll_image_print);

        // 设置点击监听事件
        llSetPrinter.setOnClickListener(this);
        llLablePrint.setOnClickListener(this);
        llTextPrint.setOnClickListener(this);
        llPDFPrint.setOnClickListener(this);
        llBarcodePrint.setOnClickListener(this);
        llImagePrint.setOnClickListener(this);
//        initHeader();
    }

    @Override
    protected void onStart() {
        super.onStart();
        initHeader();
    }

    /**
     * 初始化标题上的信息
     */
    private void initHeader() {
        setHeaderLeftText(header, "", null);
        headerConnecedState.setText(getTitleState());
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.ll_setting:
                intent = new Intent(MainActivity.this, ConnectActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_text_print:
                intent = new Intent(MainActivity.this, TextPrintActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_image_print:
                intent = new Intent(MainActivity.this, PicturePrintActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_barcode_print:
                intent = new Intent(MainActivity.this, BarcodePrintActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_lable_print:
                intent = new Intent(MainActivity.this, LabelPrintActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_pdf_print:
                intent = new Intent(MainActivity.this, PdfPrintActivity.class);
                startActivity(intent);
                break;
            default:
                break;
        }
    }
}
